package com.atguigu.foreach;

import com.atguigu.array.Student;

public class TestObjectArrays2 {
    public static void main(String[] args) {
        Student[] students = new Student[3];
        students[0] = new Student("张三", 89);
        students[1] = new Student("李四",84);
        students[2] = new Student("王五",90);

        //普通for循环
        for (int i = 0; i < students.length; i++) {
//            students[i].setScore(100);
            students[i] = new Student(students[i].getName(), 100);
        }
        for (int i = 0; i < students.length; i++) {
            System.out.println(students[i].display());
        }
        System.out.println("=========================");
        Student[] all = new Student[3];
        all[0] = new Student("张三", 89);
        all[1] = new Student("李四",84);
        all[2] = new Student("王五",90);
        //增强for循环
        for (Student student : all) {
            student.setScore(100);
//            student = new Student(student.getName(),100);
        }
        for (Student student : all) {
            System.out.println(student.display());
        }

    }
}
